Beaker = cc.Node.extend({

	ctor:function(parent,tag){
		this._super();
		parent.addChild(this,9,TAG_BEAKER_NODE);
		this.init();
	},
	init:function(tag){
		var beaker = new Button(this, 10, TAG_BEAKER,"#beaker.png", this.callback);


	},
	callback:function(p){
		var hand=new Hand();
		var action = gg.flow.flow.action;
		var func = cc.callFunc(this.actionDone, this);	
		func.retain();
		var hand = new Hand();
		//hand.addrighthand(this, "#hand/hand_left", cc.p(-25,-25),0.6);
		switch(p.getTag()){
		case TAG_BEAKER:
		
				var beaker=this.getChildByTag(TAG_BEAKER)
				var move=cc.moveBy(2,cc.p(-93,135));
				var rotate=cc.rotateTo(1.5,-100);
				var rotate1=cc.rotateTo(1.5,0);
				var delay = cc.delayTime(1.5);
				var delay1 = cc.delayTime(3.5);
				var move2=cc.moveBy(1,cc.p(93,-135));
				var seq=cc.sequence(cc.callFunc(function(){
					hand.addrighthand(this, "#hand/hand_right", cc.p(25,-15),0.6);
					
				},this),delay,move,rotate,cc.callFunc(function(){
					p.runAction(func);
				},this),delay,rotate1,move2,cc.callFunc(function(){
					hand.removehand(this, 1, 2);
				},this));
			
				var rodnode = this.getParent().getChildByTag(TAG_ROD_NODE);
				var blb=rodnode.getChildByTag(TAG_ROD);
				var move1=cc.bezierBy(2,[cc.p(-6,295),cc.p(-136,215),cc.p(-136,95)])
				//var move1=cc.moveBy(1,cc.p(-136,95));
//				var move3=cc.moveBy(1,cc.p(136,-95));
				var move3=cc.bezierBy(2,[cc.p(-6,200),cc.p(136,115),cc.p(136,-95)])
				var seq1=cc.sequence(cc.callFunc(function(){
					hand.addlefthand(rodnode, "#hand/hand_left", cc.p(-25,5),0.6);
				},this),move1,delay1,cc.delayTime(3),move3,cc.callFunc(function(){
					hand.removehand(rodnode, 1, 1);
				},this),cc.callFunc(this.flowNext, this));
				rodnode.runAction(seq1);		    		
				this.runAction(seq);

			break;



		}
	},

	actionDone:function(p){
		var action = gg.flow.flow.action;
		var func = cc.callFunc(this.actionDone, this);
		switch(p.getTag()){

		case TAG_BEAKER:
//			var fade = cc.fadeTo(0.5,0);	
//			var moveby = cc.moveBy(1.5,cc.p(0,-p.height*0.4));
//			var seq = cc.sequence(moveby,fade);
//			this.beaLine.runAction(seq);
			
			
			var beakernode = this.getParent().getChildByTag(TAG_BEAKER_NODE);
			var beaker=beakernode.getChildByTag(TAG_BEAKER);
			//beaker.setCascadeOpacityEnabled(true);
            var fade2=cc.fadeTo(0.5,0);
			beaLine2 =beaker.getChildByTag(TAG_BEAKER_LINE);
			beaLine2.runAction(cc.sequence(cc.delayTime(1.0),cc.moveTo(1,cc.p(beaker.width*0+30,beaker.height * 0+5)),fade2));
			
			if(action==ACTION_DO1)
			{
				var volumetricnode = this.getParent().getChildByTag(TAG_VOLUMETRIC_NODE);
				var volumetric=volumetricnode.getChildByTag(TAG_VOLUMETRIC);

				beaLine = new cc.Sprite("#beaker_line.png");
				beaLine.setOpacity(0);
				var fade=cc.fadeTo(0.5,150);
				var scale=cc.scaleTo(2,0.8);
				volumetricnode.addChild(beaLine,1,TAG_BEAKER_LINE1);
				beaLine.setPosition(volumetric.width * 0.1-5, volumetric.height * 0.1-90 );

				beaLine.runAction(cc.sequence(cc.delayTime(0),fade,cc.spawn(scale,cc.moveBy(2,cc.p(0,volumetric.height * 0.17)))));

		}
		if(action==ACTION_DO2)
			{
			var volumetricnode = this.getParent().getChildByTag(TAG_VOLUMETRIC_NODE);
			var volumetric=volumetricnode.getChildByTag(TAG_VOLUMETRIC);

			beaLine = volumetricnode.getChildByTag(TAG_BEAKER_LINE1);
			
			
			var scale=cc.scaleTo(1,0.6);
		
			

			beaLine.runAction(cc.sequence(cc.delayTime(0),cc.spawn(scale,cc.moveBy(2,cc.p(0,volumetric.height * 0.1)))));

			
			}
		if(action==ACTION_DO3)
		{
			var volumetricnode = this.getParent().getChildByTag(TAG_VOLUMETRIC_NODE);
			var volumetric=volumetricnode.getChildByTag(TAG_VOLUMETRIC);

			beaLine = volumetricnode.getChildByTag(TAG_BEAKER_LINE1);


			var scale=cc.scaleTo(1,0.35);



			beaLine.runAction(cc.sequence(cc.delayTime(0),cc.spawn(scale,cc.moveBy(2,cc.p(-1,volumetric.height * 0.1)))));


		}
		if(action==ACTION_DO4)
		{
			var volumetricnode = this.getParent().getChildByTag(TAG_VOLUMETRIC_NODE);
			var volumetric=volumetricnode.getChildByTag(TAG_VOLUMETRIC);
			var 

			beaLine = volumetricnode.getChildByTag(TAG_BEAKER_LINE1);

			var rodnode = this.getParent().getChildByTag(TAG_ROD_NODE);
			var blb=rodnode.getChildByTag(TAG_ROD);
			var beaker=this.getChildByTag(TAG_BEAKER);
			
			var scale=cc.scaleTo(1,0.26);



			beaLine.runAction(cc.sequence(cc.delayTime(0),cc.spawn(scale,cc.moveBy(3,cc.p(-1,volumetric.height * 0.1))),cc.delayTime(2),cc.callFunc(function(){
				blb.runAction(cc.fadeOut(0.5));
				beaker.runAction(cc.fadeOut(0.5));
			},this)));


		}
			
			break;
			
			
			



		}
	},

	flowNext:function(){

		gg.flow.next();
		cc.log("下一步"+gg.flow.flow.tag);
	}

});